package com.yunkaweilai.android.view.home;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.umeng.analytics.MobclickAgent;
import com.yunkaweilai.android.R;
import com.yunkaweilai.android.activity.CommodityActivity;
import com.yunkaweilai.android.activity.member.AddMemberInfoActivity;
import com.yunkaweilai.android.activity.member.MemberHomeLevelActivity;
import com.yunkaweilai.android.activity.operation.CommonMemberActivity;
import com.yunkaweilai.android.activity.operation.Message.GroupMessage;
import com.yunkaweilai.android.activity.operation.consumption.guadan.GuadanListActivity;
import com.yunkaweilai.android.activity.operation.consumption.room.RoomConsumptionActivity;
import com.yunkaweilai.android.activity.shop.AddPtShopActivity;
import com.yunkaweilai.android.activity.shop.AddTimeShopActivity;
import com.yunkaweilai.android.activity.web.WebActivity;
import com.yunkaweilai.android.base.BaseApplication;
import com.yunkaweilai.android.constants.Api;
import com.yunkaweilai.android.constants.Umeng;
import com.yunkaweilai.android.model.AppRuleModel;
import com.yunkaweilai.android.model.home.HomeGridModel;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName1;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName10;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName11;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName12;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName13;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName14;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName15;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName16;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName2;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName3;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName4;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName5;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName6;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName7;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName8;
import static com.yunkaweilai.android.constants.GridViewConstants.GridlistName9;

/**
 * 首页网格布局
 * 初次加载和刷新是两段同样的代码，修改的时候修改两份，少修改就会出bug
 */

public class HeaderChannelView1 extends AbsHeaderView<List<HomeGridModel>> {

    @BindView(R.id.gv_channel)
    FixedGridView gvChannel;
    private AppRuleModel.DataBean.InfoBean appRuleModel;
    private List<HomeGridModel> list1 = new ArrayList<>();
    private Context mAc;
    CommonAdapter<HomeGridModel> adapter;

    public HeaderChannelView1(Activity context) {
        super(context);
        mAc = context;
    }

    @Override
    protected void getView(List<HomeGridModel> list, ListView listView) {
        View view = mInflate.inflate(R.layout.header_channel_layout, listView, false);
        ButterKnife.bind(this, view);

        dealWithTheView(list);
        listView.addHeaderView(view);
    }

    private void dealWithTheView(final List<HomeGridModel> list) {
        list1.clear();
        list1 = list;
        gvChannel.setNumColumns(3);
        adapter = new CommonAdapter<HomeGridModel>(mActivity, R.layout.header_item_grid_view, list1) {
            @Override
            protected void convert(ViewHolder viewHolder, final HomeGridModel item, int position) {
                viewHolder.setText(R.id.id_tv_name, item.getName());
                LinearLayout linearLayout = viewHolder.getView(R.id.line_all);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (item.getName().equals(GridlistName1)) {// 计次消费
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("8")) {
                                MobclickAgent.onEvent(mAc, Umeng.JICICONSUME);
//                            mActivity.startActivity(new Intent(mActivity, JiciMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_JICI_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName2)) {//房台消费
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("7")) {
                                MobclickAgent.onEvent(mAc, Umeng.ROOMCONSUME);
                                RoomConsumptionActivity.actionStart(mActivity, "1", "0");
                            }
                        } else if (item.getName().equals(GridlistName3)) {//挂单列表
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("11")) {
                                MobclickAgent.onEvent(mAc, Umeng.GUADAN);
                                mActivity.startActivity(new Intent(mActivity, GuadanListActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName4)) {//会员管理
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("17")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_MANAGE);
//                            mActivity.startActivity(new Intent(mActivity, MemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName5)) {//新增会员
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("18")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_MEMBER);
                                mActivity.startActivity(new Intent(mActivity, AddMemberInfoActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName6)) {//会员等级
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("15")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_LEVEL);
                                mActivity.startActivity(new Intent(mActivity, MemberHomeLevelActivity.class));
//                            WebFullActivity.actionStart(mActivity, Web.MEMBER_LV_URL + "?token=" + BaseApplication.getToken());
                            }
                        } else if (item.getName().equals(GridlistName7)) {//商品管理
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("20")) {
                                MobclickAgent.onEvent(mAc, Umeng.SHOP_MANAGE);
                                BaseApplication.cleanSelectedMaps();
                                mActivity.startActivity(new Intent(mActivity, CommodityActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName8)) {//新增商品
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("21")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_SHOP);
                                mActivity.startActivity(new Intent(mActivity, AddPtShopActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName9)) {//新增计次
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("22")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_JICI);
                                mActivity.startActivity(new Intent(mActivity, AddTimeShopActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName10)) {//余额充值
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("9")) {
                                MobclickAgent.onEvent(mAc, Umeng.MONEY_RECHARGE);
//                            StoredValueSearchMember.actionStart(mActivity, "1");
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName11)) {//计次充值
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("10")) {
                                MobclickAgent.onEvent(mAc, Umeng.JICI_RECHARGE);
//                            StoredValueSearchMember.actionStart(mActivity, "2");
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER_JICI);
                            }
                        } else if (item.getName().equals(GridlistName12)) {//积分兑换
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("12")) {
                                MobclickAgent.onEvent(mAc, Umeng.INTEGRAL_EXCHANGE);
//                            mActivity.startActivity(new Intent(mActivity, IntegralMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_INTEGRAL_MEMBER);

                            }
                        } else if (item.getName().equals(GridlistName13)) {//积分调整
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("25")) {
                                MobclickAgent.onEvent(mAc, Umeng.SCORE_CHANGE);
//                            mActivity.startActivity(new Intent(mActivity, ScoreChangeActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_SCORE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName14)) {//短信群发
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("26")) {
                                MobclickAgent.onEvent(mAc, Umeng.GROUP_MESSAGE);
                                mActivity.startActivity(new Intent(mActivity, GroupMessage.class));
                            }
                        } else if (item.getName().equals(GridlistName15)) {//微会员中心
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("27")) {
                                MobclickAgent.onEvent(mAc, Umeng.WECHATCENTER);
                                WebActivity.actionStart(mAc, Api.BASE_URL + "index.php/app/MicroMemberCenter.html?token=" + BaseApplication.getToken(), "2", "微会员中心");
                            }
                        } else if (item.getName().equals(GridlistName16)) {//会员解锁
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("28")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_LOCK);
//                            mActivity.startActivity(new Intent(mActivity, LockMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER_LOCK);
                            }
                        }
                    }
                });
                ImageView view = viewHolder.getView(R.id.id_img_channel);
                view.setBackgroundResource(item.getId());
                if (item.getColorId2()) {
                    view.setColorFilter(R.color.wjx_content_txt_grey);
                }
                TextView tvName = viewHolder.getView(R.id.id_tv_name);
                tvName.setTextColor(mActivity.getResources().getColor(item.getColorId()));

            }
        };
        gvChannel.setAdapter(adapter);
        appRuleModel = BaseApplication.getAppRuleModel();
//        gvChannel.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                switch (position) {
//                    case 0:// 计次消费
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("8")) {
//                            MobclickAgent.onEvent(mAc, Umeng.JICICONSUME);
////                            mActivity.startActivity(new Intent(mActivity, JiciMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc,CommonMemberActivity.TYPE_JICI_MEMBER);
//                        }
//                        break;
//                    case 1:// 房台消费
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("7")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ROOMCONSUME);
//                            RoomConsumptionActivity.actionStart(mActivity, "1", "0");
//                        }
//                        break;
//                    case 2:// 挂单列表
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("11")) {
//                            MobclickAgent.onEvent(mAc, Umeng.GUADAN);
//                            mActivity.startActivity(new Intent(mActivity, GuadanListActivity.class));
//                        }
//                        break;
//                    case 3:// 会员管理
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("17")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_MANAGE);
////                            mActivity.startActivity(new Intent(mActivity, MemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER);
//                        }
//
//                        break;
//                    case 4:// 新增会员
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("18")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_MEMBER);
//                            mActivity.startActivity(new Intent(mActivity, AddMemberInfoActivity.class));
//                        }
//                        break;
//                    case 5:// 会员等级
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("15")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_LEVEL);
//                            mActivity.startActivity(new Intent(mActivity, MemberHomeLevelActivity.class));
////                            WebFullActivity.actionStart(mActivity, Web.MEMBER_LV_URL + "?token=" + BaseApplication.getToken());
//                        }
//                        break;
//                    case 6:// 商品管理
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("20")) {
//                            MobclickAgent.onEvent(mAc, Umeng.SHOP_MANAGE);
//                            BaseApplication.cleanSelectedMaps();
//                            mActivity.startActivity(new Intent(mActivity, CommodityActivity.class));
//                        }
//                        break;
//                    case 7:// 新增商品
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("21")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_SHOP);
//                            mActivity.startActivity(new Intent(mActivity, AddPtShopActivity.class));
//                        }
//                        break;
//                    case 8:// 新增计次
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("22")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_JICI);
//                            mActivity.startActivity(new Intent(mActivity, AddTimeShopActivity.class));
//                        }
//                        break;
//                    case 9:// 余额充值
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("9")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MONEY_RECHARGE);
////                            StoredValueSearchMember.actionStart(mActivity, "1");
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER);
//                        }
//                        break;
//                    case 10:// 计次充值
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("10")) {
//                            MobclickAgent.onEvent(mAc, Umeng.JICI_RECHARGE);
////                            StoredValueSearchMember.actionStart(mActivity, "2");
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER_JICI);
//                        }
//                        break;
//
//                    case 11:// 积分兑换
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("12")) {
//                            MobclickAgent.onEvent(mAc, Umeng.INTEGRAL_EXCHANGE);
////                            mActivity.startActivity(new Intent(mActivity, IntegralMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_INTEGRAL_MEMBER);
//
//                        }
//                        break;
//                    case 12:// 积分调整
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("25")) {
//                            MobclickAgent.onEvent(mAc, Umeng.SCORE_CHANGE);
////                            mActivity.startActivity(new Intent(mActivity, ScoreChangeActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_SCORE_MEMBER);
//                        }
//
//                        break;
//                    case 13:// 短信群发
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("26")) {
//                            MobclickAgent.onEvent(mAc, Umeng.GROUP_MESSAGE);
//                            mActivity.startActivity(new Intent(mActivity, GroupMessage.class));
//                        }
//                        break;
//                    case 14:// 微会员中心
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("27")) {
//                            MobclickAgent.onEvent(mAc, Umeng.WECHATCENTER);
//                            WebActivity.actionStart(mAc, Api.BASE_URL + "index.php/app/MicroMemberCenter.html?token=" + BaseApplication.getToken(), "2", "微会员中心");
//                        }
//                        break;
//                    case 15:// 会员解锁
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("28")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_LOCK);
////                            mActivity.startActivity(new Intent(mActivity, LockMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER_LOCK);
//                        }
//                        break;
////
////                    case 11://站内提醒
////                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("16")){
////                            WebActivity.actionStart(mActivity, Web.INSIDE_INFO + "?token=" + BaseApplication.getToken());
////                        }
////                        break;
//                }
//            }
//        });
    }

    public void refreshView(final List<HomeGridModel> list) {
//        list1.clear();
        list1 = list;
        gvChannel.setNumColumns(3);
        adapter = new CommonAdapter<HomeGridModel>(mActivity, R.layout.header_item_grid_view, list1) {
            @Override
            protected void convert(ViewHolder viewHolder, final HomeGridModel item, int position) {
                viewHolder.setText(R.id.id_tv_name, item.getName());
                LinearLayout linearLayout = viewHolder.getView(R.id.line_all);
                linearLayout.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (item.getName().equals(GridlistName1)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("8")) {
                                MobclickAgent.onEvent(mAc, Umeng.JICICONSUME);
//                            mActivity.startActivity(new Intent(mActivity, JiciMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_JICI_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName2)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("7")) {
                                MobclickAgent.onEvent(mAc, Umeng.ROOMCONSUME);
                                RoomConsumptionActivity.actionStart(mActivity, "1", "0");
                            }
                        } else if (item.getName().equals(GridlistName3)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("11")) {
                                MobclickAgent.onEvent(mAc, Umeng.GUADAN);
                                mActivity.startActivity(new Intent(mActivity, GuadanListActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName4)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("17")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_MANAGE);
//                            mActivity.startActivity(new Intent(mActivity, MemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName5)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("18")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_MEMBER);
                                mActivity.startActivity(new Intent(mActivity, AddMemberInfoActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName6)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("15")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_LEVEL);
                                mActivity.startActivity(new Intent(mActivity, MemberHomeLevelActivity.class));
//                            WebFullActivity.actionStart(mActivity, Web.MEMBER_LV_URL + "?token=" + BaseApplication.getToken());
                            }
                        } else if (item.getName().equals(GridlistName7)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("20")) {
                                MobclickAgent.onEvent(mAc, Umeng.SHOP_MANAGE);
                                BaseApplication.cleanSelectedMaps();
                                mActivity.startActivity(new Intent(mActivity, CommodityActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName8)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("21")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_SHOP);
                                mActivity.startActivity(new Intent(mActivity, AddPtShopActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName9)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("22")) {
                                MobclickAgent.onEvent(mAc, Umeng.ADD_JICI);
                                mActivity.startActivity(new Intent(mActivity, AddTimeShopActivity.class));
                            }
                        } else if (item.getName().equals(GridlistName10)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("9")) {
                                MobclickAgent.onEvent(mAc, Umeng.MONEY_RECHARGE);
//                            StoredValueSearchMember.actionStart(mActivity, "1");
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName11)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("10")) {
                                MobclickAgent.onEvent(mAc, Umeng.JICI_RECHARGE);
//                            StoredValueSearchMember.actionStart(mActivity, "2");
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER_JICI);
                            }
                        } else if (item.getName().equals(GridlistName12)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("12")) {
                                MobclickAgent.onEvent(mAc, Umeng.INTEGRAL_EXCHANGE);
//                            mActivity.startActivity(new Intent(mActivity, IntegralMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_INTEGRAL_MEMBER);

                            }
                        } else if (item.getName().equals(GridlistName13)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("25")) {
                                MobclickAgent.onEvent(mAc, Umeng.SCORE_CHANGE);
//                            mActivity.startActivity(new Intent(mActivity, ScoreChangeActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_SCORE_MEMBER);
                            }
                        } else if (item.getName().equals(GridlistName14)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("26")) {
                                MobclickAgent.onEvent(mAc, Umeng.GROUP_MESSAGE);
                                mActivity.startActivity(new Intent(mActivity, GroupMessage.class));
                            }
                        } else if (item.getName().equals(GridlistName15)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("27")) {
                                MobclickAgent.onEvent(mAc, Umeng.WECHATCENTER);
                                WebActivity.actionStart(mAc, Api.BASE_URL + "index.php/app/MicroMemberCenter.html?token=" + BaseApplication.getToken(), "2", "微会员中心");
                            }
                        } else if (item.getName().equals(GridlistName16)) {
                            if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("28")) {
                                MobclickAgent.onEvent(mAc, Umeng.MEMBER_LOCK);
//                            mActivity.startActivity(new Intent(mActivity, LockMemberActivity.class));
                                CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER_LOCK);
                            }
                        }
                    }
                });
                ImageView view = viewHolder.getView(R.id.id_img_channel);
                view.setBackgroundResource(item.getId());
                if (item.getColorId2()) {
                    view.setColorFilter(R.color.wjx_content_txt_grey);
                }
                TextView tvName = viewHolder.getView(R.id.id_tv_name);
                tvName.setTextColor(mActivity.getResources().getColor(item.getColorId()));

            }
        };
        gvChannel.setAdapter(adapter);
        appRuleModel = BaseApplication.getAppRuleModel();
//        gvChannel.setOnItemClickListener(new AdapterView.OnItemClickListener() {
//            @Override
//            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//                switch (position) {
//                    case 0:// 计次消费
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("8")) {
//                            MobclickAgent.onEvent(mAc, Umeng.JICICONSUME);
////                            mActivity.startActivity(new Intent(mActivity, JiciMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc,CommonMemberActivity.TYPE_JICI_MEMBER);
//                        }
//                        break;
//                    case 1:// 房台消费
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("7")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ROOMCONSUME);
//                            RoomConsumptionActivity.actionStart(mActivity, "1", "0");
//                        }
//                        break;
//                    case 2:// 挂单列表
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("11")) {
//                            MobclickAgent.onEvent(mAc, Umeng.GUADAN);
//                            mActivity.startActivity(new Intent(mActivity, GuadanListActivity.class));
//                        }
//                        break;
//                    case 3:// 会员管理
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("17")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_MANAGE);
////                            mActivity.startActivity(new Intent(mActivity, MemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER);
//                        }
//
//                        break;
//                    case 4:// 新增会员
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("18")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_MEMBER);
//                            mActivity.startActivity(new Intent(mActivity, AddMemberInfoActivity.class));
//                        }
//                        break;
//                    case 5:// 会员等级
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("15")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_LEVEL);
//                            mActivity.startActivity(new Intent(mActivity, MemberHomeLevelActivity.class));
////                            WebFullActivity.actionStart(mActivity, Web.MEMBER_LV_URL + "?token=" + BaseApplication.getToken());
//                        }
//                        break;
//                    case 6:// 商品管理
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("20")) {
//                            MobclickAgent.onEvent(mAc, Umeng.SHOP_MANAGE);
//                            BaseApplication.cleanSelectedMaps();
//                            mActivity.startActivity(new Intent(mActivity, CommodityActivity.class));
//                        }
//                        break;
//                    case 7:// 新增商品
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("21")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_SHOP);
//                            mActivity.startActivity(new Intent(mActivity, AddPtShopActivity.class));
//                        }
//                        break;
//                    case 8:// 新增计次
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("22")) {
//                            MobclickAgent.onEvent(mAc, Umeng.ADD_JICI);
//                            mActivity.startActivity(new Intent(mActivity, AddTimeShopActivity.class));
//                        }
//                        break;
//                    case 9:// 余额充值
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("9")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MONEY_RECHARGE);
////                            StoredValueSearchMember.actionStart(mActivity, "1");
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER);
//                        }
//                        break;
//                    case 10:// 计次充值
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("10")) {
//                            MobclickAgent.onEvent(mAc, Umeng.JICI_RECHARGE);
////                            StoredValueSearchMember.actionStart(mActivity, "2");
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_RECHARGE_MEMBER_JICI);
//                        }
//                        break;
//
//                    case 11:// 积分兑换
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("12")) {
//                            MobclickAgent.onEvent(mAc, Umeng.INTEGRAL_EXCHANGE);
////                            mActivity.startActivity(new Intent(mActivity, IntegralMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_INTEGRAL_MEMBER);
//
//                        }
//                        break;
//                    case 12:// 积分调整
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("25")) {
//                            MobclickAgent.onEvent(mAc, Umeng.SCORE_CHANGE);
////                            mActivity.startActivity(new Intent(mActivity, ScoreChangeActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_SCORE_MEMBER);
//                        }
//
//                        break;
//                    case 13:// 短信群发
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("26")) {
//                            MobclickAgent.onEvent(mAc, Umeng.GROUP_MESSAGE);
//                            mActivity.startActivity(new Intent(mActivity, GroupMessage.class));
//                        }
//                        break;
//                    case 14:// 微会员中心
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("27")) {
//                            MobclickAgent.onEvent(mAc, Umeng.WECHATCENTER);
//                            WebActivity.actionStart(mAc, Api.BASE_URL + "index.php/app/MicroMemberCenter.html?token=" + BaseApplication.getToken(), "2", "微会员中心");
//                        }
//                        break;
//                    case 15:// 会员解锁
//                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("28")) {
//                            MobclickAgent.onEvent(mAc, Umeng.MEMBER_LOCK);
////                            mActivity.startActivity(new Intent(mActivity, LockMemberActivity.class));
//                            CommonMemberActivity.actionstart(mAc, CommonMemberActivity.TYPE_MEMBER_LOCK);
//                        }
//                        break;
////
////                    case 11://站内提醒
////                        if (appRuleModel.isIs_super() || appRuleModel.getApp_rule().get("16")){
////                            WebActivity.actionStart(mActivity, Web.INSIDE_INFO + "?token=" + BaseApplication.getToken());
////                        }
////                        break;
//                }
//            }
//        });

    }

}
